package com.wy.dao.sys;

import com.domain.bean.sys.SysMenu;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:系统菜单
 * Author : wangyu
 * Date: 2018-01-23
 * Time: 14:03
 */
public interface SysMenuDAO extends BaseDAO<SysMenu,String> {

    @Query(value = "select sm from SysMenu sm join sm.roles sr join sr.users su where su.id = ?1")
    List<SysMenu> getUserMenu(String userId);


    @Query(value = "select sm from SysMenu sm " +
            "where sm.pId is null and sm.menuType = 0 order by sm.orderNum asc")
    List<SysMenu> getMenuNotSuper();

    @Query(value = "select sm from SysMenu sm " +
            "where sm.pId =:id and sm.menuType = 0 order by sm.orderNum asc")
    List<SysMenu> getMenuChildren(@Param("id")String id);

    @Query(value = "select sm from SysMenu sm " +
            "where sm.pId =:id order by sm.orderNum asc")
    List<SysMenu> getMenuChildrenAll(@Param("id")String id);
}
